﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Niknak.Social.Twitter;

namespace Demo.Business
{
    public class TwitterMessage : IMessage
    {
        public string MyCustomProperty { get { return "Custom property yo"; } }

        public string MessageId { get; set; }

        public DateTime CreatedAt { get; set; }

        public string InReplyToUserId { get; set; }

        public string InReplyToMessageId { get; set; }

        public string Source { get; set; }

        public double? Longitude { get; set; }

        public double? Latitude { get; set; }

        public string Text { get; set; }

        public string TextAsHtml { get; set; }

        public int RetweetCount { get; set; }

        public int FavouriteCount { get; set; }

        private TwitterUser _Author { get; set; }
        public IUser Author
        {
            get { return _Author; }
            set { _Author = (TwitterUser)value; }
        }

        private TwitterMessage _RetweetedMessage { get; set; }
        public IMessage RetweetedMessage
        {
            get { return _RetweetedMessage; }
            set { _RetweetedMessage = (TwitterMessage)value; }
        }

        private Message _QuotedMessage { get; set; }
        public IMessage QuotedMessage
        {
            get { return _QuotedMessage; }
            set { _QuotedMessage = (Message)value; }
        }

        private TwitterMedia[] _Media { get; set; }
        public IMedia[] Media
        {
            get { return _Media; }
            set
            {
                _Media = null;
                if (value != null && value.Any())
                    _Media = value.Cast<TwitterMedia>().ToArray();
            }
        }

        private Url[] _Urls { get; set; }
        public IUrl[] Urls
        {
            get { return _Urls; }
            set
            {
                _Urls = null;
                if (value != null && value.Any())
                    _Urls = value.Cast<Url>().ToArray();
            }
        }

        private UserMention[] _UserMentions { get; set; }
        public IUserMention[] UserMentions
        {
            get { return _UserMentions; }
            set
            {
                _UserMentions = null;
                if (value != null && value.Any())
                    _UserMentions = value.Cast<UserMention>().ToArray();
            }
        }

        private Hashtag[] _Hashtags { get; set; }
        public IHashtag[] Hashtags
        {
            get { return _Hashtags; }
            set
            {
                _Hashtags = null;
                if (value != null && value.Any())
                    _Hashtags = value.Cast<Hashtag>().ToArray();
            }
        }
    }
}
